// 拼接HTTPUrl
function url(type, pathname) {
  return window.RPConfig[type] + pathname
}

const todoApi = {
  getUnhandledTableList: params => {
    return $http.post(url('itShare', '/todoCenter/page'), params)
  },
  getProcessedTableList: params => {
    return $http.post(url('itShare', '/todoCenter/deal/pageList'), params)
  },
  // 分页查询审批管理信息
  getApprovalList: params => {
    if (params.status == '待审批') {
      params.sortPropName = 'submit_date'
      return $http.post(url('itShare', '/todoCenter/page'), params)
    } else if (params.status == '已审批') {
      params.sortPropName = 'approveDate'
      return $http.post(url('itShare', '/todoCenter/deal/pageList'), params)
    }
  },
  changeRowStatus: (params, types) => {
    if (types) {
      return $http.get(url('itShare', '/todoCenter/data/pass'), params)
    } else {
      return $http.get(url('itShare', '/todoCenter/data/reject'), params)
    }
  },
  //批量通过
  getPass: params => {
    return $http.post(url('itShare', '/todoCenter/data/batch/pass'), params)
  },
  //批量驳回
  getReject: params => {
    return $http.post(url('itShare', '/todoCenter/data/batch/reject'), params)
  },
  toRead(params) {
    return $http.get(url('itShare', '/wfRptPlantask/toReaded'), params)
  },
  batchApproval: (params, types) => {
    if (types) {
      return $http.post(url('itShare', '/todoCenter/data/batch/pass'), params)
    } else {
      return $http.post(url('itShare', '/todoCenter/data/batch/reject'), params)
    }
  },
  // 填报管理、审批管理相关
  // 获取领域列表
  getAreaCodeList: () => {
    return $http.post(url('itShare', `/fillingCenter/report/list`))
  },
  // 获取单位名称列表
  getBussinessUnit: params => {
    return $http.post(url('itShare', `/fillingCenter/trgNode/list?areaCode=${params.areaCode}`))
  },
  // 查询填报管理信息（不分页）
  getFillingInfoList: params => {
    return $http.post(url('itShare', '/fillingCenter/page/List'), params)
  },
  // 获取组织列表，用于获取单位名称
  getOrgList: params => {
    return $http.get(url('itShare', `/lc/bpmp/getOrgList?id=${params}`)).then(res => res.data.data)
  }
}

export default todoApi
